package ch11;

import java.util.ArrayList;

class _03_ArrayListSize {
	public static void main(String[] args) {
		ArrayList<Integer> list = new ArrayList<Integer>(5);
		list.add(1);
		list.add(2);
		list.add(3);		
		print(list); // [1, 2, 3] ,size :3

		list.trimToSize();		
		print(list); // [1, 2, 3] ,size :3

		list.ensureCapacity(6);		
		print(list); // [1, 2, 3] ,size :3		

		list.clear();		
		print(list); // [] ,size :0
	}

	static void print(ArrayList<Integer> list) {
		System.out.println(list + " ,size :" + list.size());
	}
}